#include<bits/stdc++.h>

using namespace std;
const int maxn = 20 + 5;
int a[maxn][maxn];
int n, m, k;
const int BOMB = 9;

int main() {
    freopen("L.in", "r", stdin);
    freopen("L.out", "w", stdout);
    cin >> n >> m >> k;
    memset(a, 0, sizeof(a));
    while (k--) {
        int x, y;
        cin >> x >> y;
        a[x][y] = BOMB;
    }
    //ͳ��ÿһ������λ�õ���Χ8��ͨ���׵�����
    for (int x = 0; x < n; x++) {
        for (int y = 0; y < m; y++) {
            if (BOMB == a[x][y])continue;
            int cnt = 0;
            for (int dx = -1; dx <= 1; dx++)
                for (int dy = -1; dy <= 1; dy++) {
                    int nx = x + dx;
                    int ny = y + dy;
                    if ((nx == x && ny == y) || nx < 0 || nx >= n || ny < 0 || ny >= m)continue;
                    if (BOMB == a[nx][ny])++cnt;
                }
            a[x][y] = cnt;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i][j] == BOMB) {
                cout << '*';
            } else {
                cout << a[i][j];
            }
        }
        cout << endl;
    }
}
/**
4 4 2
1 2
2 3
*/


/**
0111
01*2
012*
0011
*/
